package com.zt.bigdata.vertx.interceptor

import com.ecfront.dew.common.Resp
import io.vertx.ext.web.RoutingContext

import scala.concurrent.{Future, Promise}

/**
  *
  */
trait HttpAsyncFilter[E <: Animal, R] {


  def before(routingContext: RoutingContext, animal: E, future: Promise[Resp[R]]): Unit

  def after(routingContext: RoutingContext, animal: E, future: Promise[Resp[R]]): Unit

  def before(routingContext: RoutingContext, animal: E): Future[Resp[R]] = {
    val p = Promise[Resp[R]]()
    before(routingContext, animal, p)
    p.future
  }

  def after(routingContext: RoutingContext, animal: E): Future[Resp[R]] = {
    val p = Promise[Resp[R]]()
    after(routingContext, animal, p)
    p.future
  }


}
